package com.hex.ds.hdtp.core.app.data.table.dto.response;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Package com.hex.ds.hdtp.core.app.data.table.dto.response
 * @ClassName TableTransferListResponseDto
 * @Description 表迁移清单-清单ResponseDto对象
 * @Author Wang zhihao
 * @Date 2023/8/8 18:34
 * @Version v1.0
 **/
@Data
public class TableTransferListResponseDto {

    private String pkId;

    private String taskPkId;

    private String sourceDbName;

    private String sourceTableName;

    private String targetDbName;

    private String targetTableName;

    private String sourceCreateSql;

    private String targetCreateSql;

    private String isStructureUpdate;

    private String partitionFieldName;

    private List<String> partitionFieldNameList;

    private String status;

    private String sourceConnPkId;

    private String targetConnPkId;

    private String sourceConnName;

    private String targetConnName;

    private String transferMethod;

    private List<TableTransferFieldMapResponseDto> tableTransferFieldMapList;

    public List<String> getPartitionFieldNameList() {
        if (StrUtil.isNotBlank(partitionFieldName)){
            return Arrays.asList(StrUtil.split(partitionFieldName, ","));
        }
        return new ArrayList<>();
    }

    public String getSourceTable() {
        return sourceDbName + "." + sourceTableName;
    }

    public String getTargetTable() {
        return targetDbName + "." + targetTableName;
    }

}
